import http from '@/utils/request'

// 获取商品评论列表
export const getProductReviews = (productId: number | string, params?: { pageNum: number; pageSize: number }) => {
    return http.get('/order/api/orderReview/product', {
        productId,
        pageNum: params?.pageNum || 1,
        pageSize: params?.pageSize || 10
    })
}

// 获取评论详情
export const getReviewDetail = (id: number | string) => {
    return http.get(`/order/api/orderReview/${id}`)
}

// 添加评论
export const addReview = (data: any) => {
    return http.post('/order/api/orderReview', data)
}

// 修改评论
export const updateReview = (data: any) => {
    return http.put('/order/api/orderReview', data)
}

// 删除评论
export const deleteReview = (ids: number[]) => {
    return http.delete(`/order/api/orderReview/${ids.join(',')}`)
}

// 通过订单ID获取订单评论
export const getOrderReviewByOrder = (orderId: number | string) => {
    return http.get(`/order/api/orderReview/getInfoByOrder/${orderId}`)
}
